home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_071 / pwdemo / example.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  3KB  |  97 lines

  1. /* EXAMPLE.C written 09/15/86 by Martin Murray */
  2.  
  3. /* *****************************************************************************
  4. *       THIS CODE IS IN NO WAY COPYRIGHT 1986 BY INOVATRONICS, INC.  IN FACT,  *
  5. *       YOU CAN DO ANYTHING WITH IT THAT YOU WANT TO DO.  JUST REMEMBER,       *
  6. *       INOVATRONICS, INC. WILL BEAR ABSOLUTELY NO RESPONSIBILITY FOR THE USE, *
  7. *       MISUSE, INABILITY TO USE OR INABLITY TO UNDERSTAND ANY OR ALL PARTS OF *
  8. *       THIS CODE.  ENJOY IT IN GOOD HEALTH.                                   *
  9. ********************************************************************************
  10. ********************************************************************************
  11. *       THE PURPOSE OF THE CODE IS TO LET YOU SEE WHAT YOUR PowerWindows       *
  12. *       GENERATED SOURCE CODE WILL LOOK LIKE IN A PROGRAM.  IN MOST CASES, ALL *
  13. *       YOU SHOULD HAVE TO DO IS COMPILE THIS FILE.  IT WILL  AUTOMATICALLY    *
  14. *       INCLUDE YOUR SOURCE FILE, PROVIDED IT IS IN THE DEFAULT DIRECTORY, AND *
  15. *       IS NAMED "example.h".  JUST COMPILE IT, LINK IT AND RUN IT.  IT        *
  16. *       DEFAULTS TO TERMINATING WHEN THE CLOSE GADGET IS HIT, BUT IF YOU LOOK  *
  17. *       BELOW YOU'LL SEE HOW TO MAKE IT TERMINATE ON ANY EVENT AT ALL.         *
  18. ***************************************************************************** */
  19.  
  20. /* INCLUDES ********************************************************** */
  21.  
  22. #include "exec/types.h"
  23. #include "exec/io.h"
  24. #include "exec/memory.h"
  25. #include "libraries/dos.h"
  26. #include "intuition/intuition.h"
  27.  
  28. #include "example.h"
  29.  
  30. /* EXTERNALS ***************************************************** */
  31.  
  32. extern struct Window *OpenWindow();
  33.  
  34. /* GLOBALS ****************************************************** */
  35.  
  36. long IntuitionBase=0;
  37.  
  38. main()
  39. {
  40.       ULONG class;
  41.  
  42.       struct Window *wG;      /* we fetch the RastPort pointer from here */
  43.       struct RastPort *rpG;
  44.       struct IntuiMessage *message; /* the message the IDCMP sends us */
  45.  
  46.       IntuitionBase = OpenLibrary("intuition.library", 0);
  47.       if (IntuitionBase == NULL)
  48.       {
  49.             printf("intuition is not here.  where are we?\n");
  50.             goto cleanup1;
  51.       }
  52.  
  53.       wG = OpenWindow(&NewWindowStructure); /* open the window */
  54.       if ( wG == NULL )
  55.       {
  56.             printf ("open window failed\n");
  57.             goto cleanup1;
  58.       }
  59.  
  60.       rpG = wG->RPort;  /* get a rastport pointer for the window */
  61.  
  62. #ifdef MenuList
  63.       SetMenuStrip(wG,&MenuList);    /* attach any Menu */
  64. #endif
  65.  
  66. #ifdef ITextList
  67.       PrintIText(rpG,&ITextList,0,0);    /* Print the text if there is any */
  68. #endif
  69.  
  70. #ifdef BorderList
  71.       DrawBorder(rpG,&BorderList,0,0);   /* Draw the borders if there are any */
  72. #endif
  73.  
  74.      do 
  75.       {
  76.             WaitPort(wG->UserPort);
  77.                   while( (message = (struct IntuiMessage *)
  78.                          GetMsg(wG->UserPort) ) != NULL)
  79.                   {
  80.                       class = message->Class;
  81.                       ReplyMsg(message);
  82.               if ( class == CLOSEWINDOW ) goto cleanup2;
  83.                   }
  84.       } while (1);
  85.  
  86.    cleanup2:
  87. #ifdef MenuList
  88.       ClearMenuStrip(wG);
  89. #endif
  90.       CloseWindow(wG);
  91.  
  92.    cleanup1:
  93.       if (IntuitionBase != NULL) CloseLibrary(IntuitionBase);
  94.       return(0);
  95.  
  96. }
  97.